package com.zztt.logmask.common.matcher;

import com.zztt.logmask.common.handle.MaskHandle;

import java.util.ArrayList;
import java.util.List;

/**
 * 掩码处理的选择器
 */
public class DefautltMaskHandlesMatcher implements MaskHandlesMatcher{
    /**
     * 所有的掩码处理器的集合
     */
    private List<MaskHandle> maskHandles;

    public DefautltMaskHandlesMatcher(List<MaskHandle> maskHandles){
        this.maskHandles = maskHandles;
    }

    @Override
    public List<MaskHandle> matcher(CharSequence str) {
        List<MaskHandle> matchedMaskHandles = new ArrayList<MaskHandle>();
        if(maskHandles != null){
            for (MaskHandle maskHandle : maskHandles) {
                if(maskHandle.match(str)){
                    matchedMaskHandles.add(maskHandle);
                }
            }
        }
        return matchedMaskHandles;
    }
}
